package com.subfg.common.util.serializer;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;

import java.io.IOException;

public class ChangeToListSerialize extends JsonSerializer<String> {
    @Override
    public void serialize(String value, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException {
        String[] usiArrays = value.substring(1, value.length() - 1).split(",");
        jsonGenerator.writeStartArray();
        for (String element : usiArrays) {
            jsonGenerator.writeString(element);
        }
        jsonGenerator.writeEndArray();
    }
}
